package com.jkoss.biz.imp.kc;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.jkoss.biz.kc.coursebiz;
import com.jkoss.dao.kc.CoursemodelMapper;
import com.jkoss.pojo.kc.Coursemodel;
import com.jkoss.pojo.kc.CoursemodelExample;
import com.jkoss.tool.Page;

@Component
public class coursebizimp implements coursebiz{
    
	@Autowired
	private CoursemodelMapper cdao;
	
	
	@Override
	public List<Coursemodel> findCourseByAll() {
		// TODO Auto-generated method stub
		return cdao.findByAll();
	}
	@Override
	public Coursemodel findKcByOne(Integer kcmdelid) {
		// TODO Auto-generated method stub
		return cdao.findByOne(kcmdelid);
	}
	
	@Override
	@Transactional
	public int upkcmodel(Coursemodel csm) {
		// TODO Auto-generated method stub
		return cdao.updateByPrimaryKey2(csm);
	}
	@Override
	@Transactional
	public int addkcmodel(Coursemodel csm) {
		// TODO Auto-generated method stub
		return cdao.insert2(csm);
	}
	@Override
	public int delkcmodel(String kCModelID) {
		// TODO Auto-generated method stub
		int kcmoderid = Integer.parseInt(kCModelID);
		return cdao.deleteByPrimaryKey(kcmoderid);
	}
	@Override
	public List<Coursemodel> findListCourse(Page<Coursemodel> page,Integer kcid) {
		
		if(kcid==null||kcid==0){
			return cdao.findListCourse(page);
		}
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("kcid", kcid);
		page.setParams(params);
		return cdao.findListCourse2(page);
	}
	@Override
	public List<Coursemodel> findByAll() {
		
		return cdao.findByAll2();
	}
	
	@Override
	public Coursemodel findTheSame(Integer kcid, String kcmdelName) {
		
		return cdao.findTheSame(kcid,kcmdelName);
	}

}
